/*
 *   Copyright 2012, Thomas Kerber
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
package milk.jpatch.fileLevel;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import milk.jpatch.Util;

/**
 * Patch denoting that a file does not change.
 * @author Thomas Kerber
 * @version 1.0.1
 */
public class FileID extends FilePatch{
    
    /**
     * Creates.
     * @param name The filename.
     */
    public FileID(String name){
        super(name);
    }
    
    @Override
    public void patch(InputStream in, OutputStream out) throws IOException{
        if(in != null)
            Util.loop(in, out);
        else{
            out.close();
        }
    }
    
    @Override
    public void serialize(File root){
        // Do nothing.
    }
    
    /**
     * 
     * @param f A file.
     * @return If the file can be deserialized.
     */
    public static boolean canDeserializeAt(File f){
        return false;
    }
    
    /**
     * Deserializes a file in relation to a root dir.
     * @param root The root dir.
     * @param f The file.
     * @return The deserialization.
     */
    public static FileID deserializeAt(File root, File f){
        throw new IllegalStateException(
                "FileID cannot be deserialized as it isn't serialized.");
    }
    
}
